<?php include template('header','admin');?>
<div class="content padding-big have-fixed-nav">
		<div class="tips margin-tb">
			<div class="tips-info border">
				<h6>温馨提示</h6>
				<a id="show-tip" data-open="true" href="javascript:;">关闭操作提示</a>
			</div>
			<div class="tips-txt padding-small-top layout">
				<p>- 不选择条件则导出所有订单</p>
			</div>
		</div>
	<body>
		
		<div class="content padding-big have-fixed-nav">
			<form name="form" action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" enctype="multipart/form-data">
			<div class="form-box clearfix">
				
				<?php echo Form::input('calendar', 'starttime', $startime_text, '开始时间', '开始时间'); ?>
				<?php echo Form::input('calendar', 'endtime', $endtime_text, '结束时间', '结束时间'); ?>

			
				<div class="form-group" style="z-index: 2;">
				        <span class="label">订单状态</span>
				        <div class="box" style="width: 256px;">
			                <div class="form-select-edit select-search-text-box brand_list">
			                    <div class="form-buttonedit-popup">
			                        <input class="input" type="text" value="" readonly="readonly" data-reset="false">
			                        <span class="ico_buttonedit"></span>
			                        <input type="hidden" name="status" value="<?php echo $v[$k]?>" data-reset="false">
			                    </div>
			                    <div class="select-search-field border border-main">
		                    		<input class="input border-none" autocomplete="off" type="text" id="" value="" placeholder="" data-reset="false" />
		                    		<i class="ico_search"></i>
		                    	</div>
			                    <div class="listbox-items brand-list">

			                    <?php foreach ($status AS $k=>$v) {?>
			                    	<span class="listbox-item" data-val="<?php echo $v?>"><?php echo $k?></span>
			                    <?php }?>
			                   </div>
			                </div>
				        </div>
				</div>
                
				<div class="form-group" style="z-index: 2;">
				        <span class="label">选择商家：</span>
				        <div class="box" style="width: 256px;">
			                <div class="form-select-edit select-search-text-box seller_list">
			                    <div class="form-buttonedit-popup">
			                        <input class="input" type="text" value="<?php echo $info['seller_name']?>" readonly="readonly" data-reset="false">
			                        <span class="ico_buttonedit"></span>
			                        <input type="hidden" name="id" value="<?php echo $supplier['id']?>" data-reset="false">
                                    <input type="hidden" name="supplier_name" value="<?php echo $supplier['supplier_name']?>" data-reset="false">
			                  </div>
			                    <div class="select-search-field border border-main">
		                    		<input class="input border-none" autocomplete="off" type="text" id="seller_name" value="" placeholder="请输入商家名称" data-reset="false" />
		                    		<i class="ico_search"></i>
		                    	</div>
			                    <div class="listbox-items seller-list">
			                    <?php foreach ($suppliers AS $supplier) {?>
			                    	<span class="listbox-item <?php if ($supplier['id'] == $suppliers['id']) :?>listbox-item-selected<?php endif;?>" data-val="<?php echo $supplier['id']?>" data-name="<?php echo $supplier['supplier_name']?>"><?php echo $supplier['supplier_name']?></span>
			                    <?php }?>
			                   </div>
			                </div>
				        </div>
				</div> 

			

			</div>
			<div class="padding">
				<?php if(isset($id)):?>
					<input type="hidden" name="id" value="<?php echo $id?>" />
				<?php endif;?>
				<input type="hidden" name="type" value="" />
				<input type="submit" class="button bg-main" value="导出" />

			</div>
			</form>
		</div>
		<script src="/statics/js/laydate/laydate.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(window).otherEvent();
			var position_json = <?php echo json_encode($position_format)?>;
			//切换效果

			function loadBegin(position_type){
				$('input[name="type"]').val(position_type);
				if(position_type=="0"){
					$(".form-group:eq(4)").show();
					$(".form-group:eq(5)").hide();
				}else{
					$(".form-group:eq(4)").hide();
					$(".form-group:eq(5)").show();
				}
			}
			$(function(){
				//模拟第一个点击
				if($('input[name="position_id"]').val()=='')$('.listbox-items span:eq(0)').trigger('click');
				$("[name=form]").Validform({
					beforeSubmit:function(curform){
						var startTime = $('input[name="starttime"]').val();
						var endTime = $('input[name="endtime"]').val(); 
						var d1 = new Date(startTime.replace(/\-/g, "\/")); 
						var d2 = new Date(endTime.replace(/\-/g, "\/")); 
						if(startTime !="" && endTime !="" && d1 >= d2){ 
							alert("开始时间不能大于结束时间！"); 
							return false; 
						}
						
					}
				});
		
				//日期时间 
				laydate.skin('danlan');
				var start = {
				    elem: '#start',
				    format: 'YYYY-MM-DD hh:mm:ss',
				    min: laydate.now(), //设定最小日期为当前日期
				    max: '2099-06-16 23:59:59', //最大日期
				    istime: true,
				    istoday: true,
				    choose: function(datas){
				         end.min = datas; //开始日选好后，重置结束日的最小日期
				         end.start = datas //将结束日的初始值设定为开始日
				    }
				};
				var end = {
				    elem: '#end',
				    format: 'YYYY-MM-DD hh:mm:ss',
				    min: laydate.now(),
				    max: '2099-06-16 23:59:59',
				    istime: true,
				    istoday: true,
				    choose: function(datas){
				        start.max = datas; //结束日选好后，重置开始日的最大日期
				    }
				};
				laydate(start);
				laydate(end);
			})

		
	
					$('.select-search-field').click(function(e){
					e.stopPropagation();
				});
				//buttonedit-popup-hover
				$('.select-search-text-box .form-buttonedit-popup').click(function(){
					if(!$(this).hasClass('buttonedit-popup-hover')){
						$(this).parent().find('.select-search-field').show();
						$(this).parent().find('.select-search-field').children('.input').focus();
						$(this).parent().find('.listbox-items').show();
					}else{
						$(this).parent().find('.select-search-field').hide();
						$(this).parent().find('.listbox-items').hide();
					}
				});
				$('#brandname').live('keyup',function(){
					var url = "<?php echo url('ajax_brand')?>";
					var brandname = this.value;
					$.post(url,{brandname:brandname},function(data){
						$('.brand-list').children('.listbox-item').remove();
						if(data.status == 1){
							var html = '';
							$.each(data.result,function(i,item){
								 html += '<span class="listbox-item" data-val="' + i + '">' + item + '</span>';
							})
							$('.brand-list').append(html);
						}else{
							var html = '<span class="listbox-item">未搜索到结果</span>';
							$('.brand-list').append(html);
						}
					},'json')
				})
				$(".brand_list .listbox-items .listbox-item").live('click',function(){
					$(this).parent().prev('.select-search-field').children('.input').val();
					$(this).parent().prev('.select-search-field').hide();
					$('.brand_list .form-buttonedit-popup .input').val($(this).html());
					$('input[name=status]').val($(this).attr('data-val'));
				});
                
				$('#seller_name').live('keyup',function(){
					var url = "<?php echo url('ajax_seller_name')?>";
					var sellername = this.value;
					$.post(url,{seller_name:sellername},function(data){
						$('.seller-list').children('.listbox-item').remove();
						if(data.status == 1){
							var html = '';
							$.each(data.result,function(i,item){
								 html += '<span class="listbox-item" data-val="' + i + '" data-name="' + item + '">' + item + '</span>';
							})
							$('.seller-list').append(html);
						}else{
							var html = '<span class="listbox-item">未搜索到结果</span>';
							$('.seller-list').append(html);
						}
					},'json')
				})
				$(".seller_list .listbox-items .listbox-item").live('click',function(){
					$(this).parent().prev('.select-search-field').children('.input').val();
					$(this).parent().prev('.select-search-field').hide();
					$('.seller_list .form-buttonedit-popup .input').val($(this).html());
					$('input[name=id]').val($(this).attr('data-val'));
                    $('input[name=supplier_name]').val($(this).attr('data-name'));
				});

		</script>
	</body>
</html>
